using System;

namespace ActivUFRJ.Classes.Artefato
{
    public class DBHistorico : Connection.MySQL
    {
        public DBHistorico() : base(ref Connection.DBConnection.myConnection)
        {

        }

        /*
        private void FillHistorico(Historico Historico)
        {
            Historico.ID = Convert.ToInt32(TableGetValue("ANA_ID"));
            Historico.Descricao = Convert.ToString(TableGetValue("ANA_Descricao"));
        }

        internal void CarregarHistorico(Historico Historico)
        {
            try
            {
                string SQL = "SELECT * from artefato_notas_avaliacao where ANA_ID = " + Historico.ID.ToString();

                this.SetSQL(SQL);
                if (!this.IsTableOver())
                {
                    FillHistorico(Historico);
                }
                this.Dispose();
            }
            catch (Exception ex)
            {

            }
        }
        */

        internal System.Data.DataTable GetHistoricoDT(Artefato artefato, int numeroVersoes)
        {
            try
            {

                string SQL = "SELECT AH_ID, AH_DATA_VERSAO, AH_COMENTARIO, CONCAT(usr_nome, ' ', usr_sobrenome)  AS USR_Nome_Completo FROM artefato_historico " +
                                "inner join USUARIOS on " +
                                "artefato_historico.USR_ID_AUTOR_CADASTRO = USUARIOS.USR_ID " +
                                " where art_id = " + artefato.ID.ToString();

                if (numeroVersoes > 0) SQL += " limit " + numeroVersoes.ToString();

                this.SetSQL(SQL);
                return this.ReturnTable();

            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}
